﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="pol_soidukid2_paring", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(PolSoidukid2Paring))]
    public class PolSoidukid2ParingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IPolSoidukid2Paring clazz;
        
        public PolSoidukid2ParingSerializer(IPolSoidukid2Paring clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Id!=null) {
                Writer.WriteStartElement("id");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Id))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.RegMrk!=null) {
                Writer.WriteStartElement("reg_mrk");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RegMrk))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Vinkood!=null) {
                Writer.WriteStartElement("vinkood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Vinkood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Regtun!=null) {
                Writer.WriteStartElement("regtun");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regtun))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Mark!=null) {
                Writer.WriteStartElement("mark");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mark))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Mudel!=null) {
                Writer.WriteStartElement("mudel");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mudel))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Aasta!=null) {
                Writer.WriteStartElement("aasta");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Aasta))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Varvus!=null) {
                Writer.WriteStartElement("varvus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Varvus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Keretyyp!=null) {
                Writer.WriteStartElement("keretyyp");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Keretyyp))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikid!=null) {
                Writer.WriteStartElement("isikid");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Isikid))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Eesnimi!=null) {
                Writer.WriteStartElement("eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Perenimi!=null) {
                Writer.WriteStartElement("perenimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Perenimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Synniaeg!=null) {
                Writer.WriteStartElement("synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Synniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Isikukood!=null) {
                Writer.WriteStartElement("isikukood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KuvaKehtetud!=null) {
                Writer.WriteStartElement("kuva_kehtetud");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.KuvaKehtetud))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Max!=null) {
                Writer.WriteStartElement("max");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Max))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "id")) {
                goto id;
            }
            else {
                if ((Reader.LocalName == "reg_mrk")) {
                    goto reg_mrk;
                }
                else {
                    if ((Reader.LocalName == "vinkood")) {
                        goto vinkood;
                    }
                    else {
                        if ((Reader.LocalName == "regtun")) {
                            goto regtun;
                        }
                        else {
                            if ((Reader.LocalName == "mark")) {
                                goto mark;
                            }
                            else {
                                if ((Reader.LocalName == "mudel")) {
                                    goto mudel;
                                }
                                else {
                                    if ((Reader.LocalName == "aasta")) {
                                        goto aasta;
                                    }
                                    else {
                                        if ((Reader.LocalName == "varvus")) {
                                            goto varvus;
                                        }
                                        else {
                                            if ((Reader.LocalName == "keretyyp")) {
                                                goto keretyyp;
                                            }
                                            else {
                                                if ((Reader.LocalName == "isikid")) {
                                                    goto isikid;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "eesnimi")) {
                                                        goto eesnimi;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "perenimi")) {
                                                            goto perenimi;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "synniaeg")) {
                                                                goto synniaeg;
                                                            }
                                                            else {
                                                                if ((Reader.LocalName == "isikukood")) {
                                                                    goto isikukood;
                                                                }
                                                                else {
                                                                    if ((Reader.LocalName == "kuva_kehtetud")) {
                                                                        goto kuva_kehtetud;
                                                                    }
                                                                    else {
                                                                        if ((Reader.LocalName == "max")) {
                                                                            goto max;
                                                                        }
                                                                        else {
                                                                            return;
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        id:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>id");
            }
            clazz.Id = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("id")).Value;
            goto START;
        reg_mrk:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>reg_mrk");
            }
            clazz.RegMrk = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("reg_mrk")).Value;
            goto START;
        vinkood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>vinkood");
            }
            clazz.Vinkood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vinkood")).Value;
            goto START;
        regtun:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>regtun");
            }
            clazz.Regtun = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regtun")).Value;
            goto START;
        mark:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>mark");
            }
            clazz.Mark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mark")).Value;
            goto START;
        mudel:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>mudel");
            }
            clazz.Mudel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mudel")).Value;
            goto START;
        aasta:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>aasta");
            }
            clazz.Aasta = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("aasta")).Value;
            goto START;
        varvus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>varvus");
            }
            clazz.Varvus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("varvus")).Value;
            goto START;
        keretyyp:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>keretyyp");
            }
            clazz.Keretyyp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("keretyyp")).Value;
            goto START;
        isikid:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>isikid");
            }
            clazz.Isikid = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("isikid")).Value;
            goto START;
        eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>eesnimi");
            }
            clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
            goto START;
        perenimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>perenimi");
            }
            clazz.Perenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("perenimi")).Value;
            goto START;
        synniaeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>synniaeg");
            }
            clazz.Synniaeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("synniaeg")).Value;
            goto START;
        isikukood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>isikukood");
            }
            clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("isikukood")).Value;
            goto START;
        kuva_kehtetud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>kuva_kehtetud");
            }
            clazz.KuvaKehtetud = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("kuva_kehtetud")).Value;
            goto START;
        max:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>pol_soidukid2_paring>max");
            }
            clazz.Max = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("max")).Value;
            goto START;
        }
    }
}
